<template>
	<view>
		<u-navbar :border-bottom='false' back-icon-size='48' title="全部评价"></u-navbar>
		<view class="content" v-if="reviewList.length">
			<view class="content-li" v-for="(item,index) in reviewList" :key='index'>
				<view class="head">
					<image class="headPic" :src="item.head_pic" mode=""></image>
					<view class="info">
						<text class="name">{{item.nickname}}</text>
						<text class="date">{{item.create_time}}</text>
					</view>
				</view>
				<view class="bottom">
					<view class="text">
						{{item.content}}
					</view>
					<view class="imgs">
						<image v-for="item in item.videos" :src="item" mode=""></image>
					</view>
				</view>
				<view class="isLike" v-if="item.is_like == 1" @click="likeFn(item.id)">
					<u-icon name="heart-fill" color="#EC3A54" size="32"></u-icon> <text style="margin-left: 8rpx;">{{item.like_num}}</text>
				</view>
				<view class="isLike" v-if="item.is_like == 0" @click="likeFn(item.id)">
					<u-icon name="heart" color="#333333" size="32"></u-icon> <text style="margin-left: 8rpx;">{{item.like_num}}</text>
				</view>
			</view>
		</view>
		<view class="noCont" v-else>
				<u-empty text="暂无评论" mode="list"></u-empty>
		</view>
	
	</view>
</template>

<script>
	import myRequest from '@/api/index.js'
	export default {
		data() {
			return {
				page:'1',
				reviewList:[],
				id:'',//线路id
			}
		},
		onReachBottom() {
			let page = Number(this.page) + 1
			this.page = page.toString()
			this.getReview()
		},
		onLoad(option) {
			this.id = option.id
			this.getReview()
		},
		methods:{
			// 获取评论
			async getReview() {
				let {id,page} =this
				let res = await myRequest.getComment({
					page:page,
					num:'5',
					category_type: '2',
					source_id:id
				})
				if (res.status) {
					this.reviewList = res.data
				}
			},
			// 点赞,消赞
			async likeFn(id){
				let res =await myRequest.giveLike({
					forum_id:id
				})
				if(res.status) {
					this.getReview()
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		padding:0 20rpx 20rpx; 
		.content-li {
			width: 100%;
			height: auto;
			border-radius: 16rpx;
			background-color: #FFFFFF;
			padding: 0 20rpx;
			margin-top: 20rpx;
			.head {
				width: 100%;
				height: 120rpx;
				display: flex;
				align-items: center;
		
				.headPic {
					width: 92rpx;
					height: 92rpx;
					border-radius: 50%;
				}
		
				.info {
					margin-left: 16rpx;
					display: flex;
					flex-direction: column;
		
					.name {
						font-size: 28rpx;
						font-family: Segoe UI;
						font-weight: 400;
						color: #333333;
					}
		
					.date {
						font-size: 24rpx;
						font-family: Segoe UI;
						font-weight: 400;
						color: #999999;
					}
				}
			}
		
			.bottom {
				.text {
					font-size: 28rpx;
					font-family: Segoe UI;
					font-weight: 400;
					color: #333333;
				}
		
				.imgs {
					margin-top: 24rpx;
					display: flex;
					flex-wrap: wrap;
					justify-content: space-between;
		
					image {
						margin-bottom: 4rpx;
						width: 216rpx;
						height: 216rpx;
					}
				}
			}
			.isLike {
				width: 100%;
				height: 76rpx;
				line-height: 76rpx;
				text-align: right;
				font-size: 28rpx;
				font-family: Segoe UI;
				font-weight: 400;
				color: #333333;
			}
		}
	}
	.noCont {
		padding-top: 320rpx;
	}
</style>
